package com.zzj.controller;

import com.github.pagehelper.PageInfo;
import com.zzj.ServiceImpl.QualityServiceImpl;
import com.zzj.bean.ProductBean;
import com.zzj.service.Product;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("quality")
//@CrossOrigin
public class QualityController {
    @Resource
    private Product dao;
    @Resource
    private QualityServiceImpl service;
    @GetMapping("findAll")
    public PageInfo<ProductBean> findAll(@RequestParam(defaultValue = "1") int pageNum,
                                                 @RequestParam(defaultValue = "5") int pageSize){


        System.out.println("进来了");
        PageInfo<ProductBean> all = dao.getAll(pageNum,pageSize);
        System.out.println(all+"11111111111111111111");
        return all;

    }
    @RequestMapping("findOne")
    public Map findOne(int pid,int pstate){
        System.out.println("pid===="+pid);
        System.out.println("pstate======"+pstate);
        Map map = service.selectOne(pid, pstate);
        return map;
    }
    @GetMapping("rebut")
    public boolean rebutOne(int pid ,int pstate){
        boolean b = service.rebutOneProduct(pid, pstate);
        return b;
    }
    @PostMapping("approve/{pid}/{pstate}")
    public boolean ApprovedOne(@PathVariable("pid") int pid,
                               @PathVariable("pstate")int pstate){
        boolean b = service.ApprovedOneProduct(pid, pstate);
        return b;
    }
}
